import { h, resolveComponent } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'

const routes = [
  {
    path: '/',
    redirect: '/main',
    component: () => import('@/App.vue')
  },
  {
    path: '/main',
    component: () => import('@/views/main/index.vue'),
    name: 'main',
    meta: { title: '主应用1' }
  },
  {
    path: '/main/test',
    component: () => import('@/views/main/test.vue'),
    name: 'test',
    meta: { title: '主应用2' }
  },
  {
    path: '/:pathMatch(.*)*',
    component: { render: () => h(resolveComponent('router-view')) },
    meta: {
      title: '微应用'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
